<template>
    <view class="content">
    </view>
</template>

<script>
    import { updateUserInfo } from 'libraries/apis/user';

    export default {
        name: 'index',
        data() {
            return {
                schoolId: '',
                userInfo: {},
                defaultAvatar: 'https://cdn.dragonmate.hhzy.fun/user/e0ad7e2078cc11eb9a47293aaf31f57e.png',
                businessType: '',
                businessAuth: []
            };
        },
        methods: {
            async onShow() {

            },
            updateUserInfo() {
                uni.getUserProfile({
                    desc: '用于完善会员资料',
                    success: async (res) => {
                        this.userInfo = {
                            avatar: res.userInfo.avatarUrl,
                            nickname: res.userInfo.nickName
                        };
                        uni.showToast({
                            title: '信息更新成功!',
                            icon: 'success'
                        });
                        // 更新用户数据
                        await updateUserInfo({
                            nickName: res.userInfo.nickName,
                            avatarUrl: res.userInfo.avatarUrl
                        });

                        await this.$store.dispatch('user/updateUserInfo');
                    },
                    fail() {
                        uni.showToast({
                            title: '信息更新失败',
                            icon: 'none'
                        });
                    }
                });
            }
        }
    };
</script>

<style lang="scss" scoped>
@import "~styles/global.scss";
.content {
    background-color: #f4f4f4;
}
</style>
